"""
"""

import os
import tempfile


DEXEN_DIR = os.path.join(tempfile.gettempdir(), "dexen")


def create_dir(path, *args):
    if not os.path.exists(path):
        os.mkdir(path)
    for arg in args:
        path = os.path.join(path, arg)
        if not os.path.exists(path):
            os.mkdir(path)
    return path


def get_node_dir(node_name, create=False):
    if create:
        create_dir(DEXEN_DIR, node_name)
    return os.path.join(DEXEN_DIR, node_name)


def get_job_dir(worker_name, user_name, job_name, create=False):
    if create:
        create_dir(DEXEN_DIR, worker_name, user_name, job_name)
    return os.path.join(DEXEN_DIR, worker_name, user_name, job_name)


def get_worker_dir(worker_name, create=False):
    if create:
        create_dir(DEXEN_DIR, worker_name)
    return os.path.join(DEXEN_DIR, worker_name)
